package com.lm.Prototype;

import java.util.Arrays;
import java.util.List;

public class Prototype2 implements Cloneable{
    private List<String> hobby;
    public void setHobby(List<String> hobby) {this.hobby = hobby;}
    public List<String> getHobby() {return hobby;}

    public Prototype2() {}

    public Object clone() throws CloneNotSupportedException {
        return (Prototype2) super.clone();
    }

    public static void main(String[] args) throws CloneNotSupportedException {
        //创建原型对象
        Prototype2 prototype = new Prototype2();
        prototype.setHobby(Arrays.asList("篮球", "读书", "看美女"));
        //基于原型对象创建新对象
        Prototype2 clone = (Prototype2) prototype.clone();
        System.out.println("prototype == clone:"+(prototype == clone));//true
        System.out.println("prototype.hobby == clone.hobby:"+(prototype.getHobby() == clone.getHobby()));//true
    }
}
